<template>
	<!-- 商家扫码核销成功 -->
	<view class="w_wp">
		<view class="w_info">
			<image src="/static/homeback.png" class="back" @click="$navTo('/pages/index/index')"></image>
			<view class="w_name">
				<view><image src="/static/Home_Icon/user.png"></image>会员：{{info.nickname}}</view>
				<view><image src="/static/Home_Icon/gouwuche1.png"></image>下单时间：{{info.createtime}}</view>
				<view><image src="/static/Home_Icon/tuan.png"></image>订单号：{{info.ordersn}}</view>
			</view>
			<view class="w_li">
				<image :src="info.thumb" mode=""></image>
				<view class="">
					<view class="goods_title">{{info.goodstitle}}</view>
					<view class="goods_title">剩余次数：<text class="bold">{{info.lastnum}}</text></view>
				</view>
			</view>
			<view class="w_li">
				<text style="margin-right: 25rpx;">选择核销次数：</text>
				<uni-number-box style="transform: scale(1.15);" :min="1" :max="info.lastnum" v-model="number"></uni-number-box>
			</view>
			<view class="w_name">
				<view><image src="/static/price.png"></image>价格：<text class="bold">{{formattedPrice}}</text> 元</view>
			</view>
			<view class="w_name">
				<view><image src="/static/Home_Icon/gouwuche1.png"></image>支付时间：{{info.paytime}}</view>
			</view>
			<button class="w_bottom" @click="submit">确认核销</button>
			<!-- <image src="/static/homeback.png" class="back" @click="$navTo('/pages/index/index')"></image>
			<view class="w_name">
				<view><image src="/static/Home_Icon/wo2.png"></image>会员：沈丘县多米街运营中心</view>
				<view><image src="/static/Home_Icon/gouwuche1.png"></image>下单时间：2024-01-18 08:06:53</view>
				<view><image src="/static/Home_Icon/ding.png"></image>订单号：TG20240116195640256466</view>
			</view>
			<view class="w_li">
				<image src="https://img.jinghushi.com/images/9/2024/01/I2EnT51X12451Pt1t4Z5Tzn5n4j111.jpeg" mode=""></image>
				<view class="">
					<view class="goods_title">次卡次卡次卡</view>
					<view class="goods_title">剩余次数：<text class="bold">5</text></view>
				</view>
			</view>
			<view class="w_li">
				<text style="margin-right: 25rpx;">选择核销次数：</text>
				<uni-number-box style="transform: scale(1.15);" :min="1" :max="5" v-model="number"></uni-number-box>
			</view>
			<view class="w_name">
				<view><image src="/static/price.png"></image>价格：<text class="bold">{{formattedPrice}}</text> 元</view>
			</view>
			<view class="w_name">
				<view><image src="/static/Home_Icon/gouwuche1.png"></image>支付时间：2024-01-20 10:00:02</view>
			</view>
			<button class="w_bottom" @click="submit">确认核销</button> -->
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				content: '',
				sig: '',
				info: {
					ordersn: '',
					nickname: '',
					price: '',
					createtime: '',
					paytime: '',
					thumb:'',
					goodstitle:'',
					
				},
				number: 1
			}
		},
		onLoad(option) {
			if (option.scene) {
				this.content = this.gup('content', '?' + option.scene);
				this.sig = this.gup('sig', '?' + option.scene);
			} else if (option.q) {
				let scan_url = decodeURIComponent(option.q);
				this.content = this.gup('content', scan_url);
				this.sig = this.gup('sig', scan_url);
			} else {
				this.content = option.content;
				this.sig = option.sig;
			}
			this.getInfo();
		},
		computed: {
		  formattedPrice() {
			// return parseFloat((0.2*this.number).toFixed(2))
		    return parseFloat((this.info.price*this.number).toFixed(2))
		  }
		},
		methods: {
			gup(name, url) {
				if (!url) url = location.href;
				name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
				var regexS = "[\\?&]" + name + "=([^&#]*)";
				var regex = new RegExp(regexS);
				var results = regex.exec(url);
				return results == null ? null : results[1];
			},
			getInfo() {
				this.$axios('card/cardheckInfo', 'POST', 'order', {
					content: this.content,
					sig: this.sig
				}).then(res => {
					if (res.data.code == 200) {
						this.info = res.data.data;
					}
				})
			},
			submit() {
				this.$axios('card/cardheck', 'POST', 'order', {
					// id: this.info.id,
					content: this.content,
					sig: this.sig,
					num: this.number
				}).then(res => {
					if (res.data.code == 200) {
						this.$api.msg('核销成功！');
						setTimeout(() => {
							uni.reLaunch({
								url: '/pages/individualism/user'
							});
						}, 1000)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #f2f2f2;
	}

	.w_wp {
		color: $font-color-dark;
		padding-bottom: 130upx;
	}

	.w_info {
		background-color: #fff;
		padding: 20upx;
	}

	.w_name,
	.w_order {
		line-height: 1.8;
	}
	.back{
		width: 239rpx;
		height: 64rpx;
	}
	.w_name {
		view{
			display: flex;
			align-items: center;
			line-height: 2.3;
			font-size: 32rpx;
			image{
				width: 40rpx;
				height: 40rpx;
				margin-right: 10rpx;
			}
		}
	}

	.w_order {
		font-weight: bold;
		font-size: 26upx;
		text-align: center;
	}
	.bold{
		color : $bg-color;
		font-weight: bold;
	}
	.w_money {
		color: $base-color;
	}

	.w_li {
		font-weight: bold;
		margin-top: 20rpx;
		display: flex;
		align-items: center;
		line-height: 2;
		font-size: 32rpx;
		padding-left: 40rpx;
		view{
			flex: 1;
			.goods_title{
				word-break: break-all;
			}
		}
	}
	.flex{
		display: flex;
		flex-direction: column;
		align-items: center;
		line-height: 70rpx;
		margin-bottom: 25rpx;
	}
	.w_li image {
		height: 150rpx;
		width: 150rpx;
		border-radius: 10rpx;
		margin-right: 20rpx;
	}
	.w_bottom {
		background: $base-color;
		border-radius: 10upx;
		color: #fff;
		margin: 40upx 0;
		line-height: 86upx;
		letter-spacing: 1px;
		text-align: center;
		box-shadow: 4rpx 5rpx 17rpx 7rpx #ddd;
	}
</style>